function [index] = preamble_search(inp,thresh,preamble)
NP=numel(preamble);
T=zeros(1,numel(inp)-NP);
r=zeros(1,NP);
c=zeros(1,numel(inp)-NP);
for index_=NP+1:numel(inp)
r=inp(index_-NP:index_-1);
c(index_ - NP)=r*preamble;
T(index_ - NP)=abs(c(index_ - NP))^2/abs(r*r');
    if T(index_ - NP)>thresh
        index=index_;
        break;
    end
end